<?php
//核心控制器
class Controller {
	
	public function __construct(){
		$this->checkLogin();
		
		
	}
	
	//验证用户是否登录
	public function checkLogin(){
		if (!isset($_SESSION['admin_name'])) {
			//未登录
			header("location:index.php?c=login&a=login");
		}
		//这里还要进行一次验证预防修改密码后还可以使用旧的session进行操作
	}
	
	
	//提示信息并跳转
	public function jump($url,$message,$wait = 3){
		if ($wait == 0) {
			//立即跳转
			header("Location:$url");
		} else {
			$nav=$this->getNavs();
			$title="提示";
			$include_file="message";
			include VIEWS_PATH . "index.html";
		}
		//一定要退出
		exit();
	}
	
	//载入工具类模型
	public function library($lib){
		include LIB_PATH . "{$lib}.class.php";
	}
	
	//载入辅助函数
	public function helper($helper){
		include HELPER_PATH . "{$helper}.php";
	}
	
	//获取导航
	public function getNavs(){
		$admin_name=$_SESSION['admin_name'];
		$admin_pwd=$_SESSION['admin_pwd'];
		$indexmodel=new IndexModel("tb_manager");
		
		return $indexmodel->getNav($admin_name,$admin_pwd);

	}
	
	
	//获取底部footer信息
	public function getFooter(){
		$librarymodel=new LibraryModel("tb_library");
		return $this->libraryinfo=$librarymodel->getLibInfo();
	}
	
	
	//调试die
	public function diehere($data){
		var_dump($data);
		die();
	}

	
}